<template>
	<div id="app" >
		<router-view v-if="isRouterAlive"></router-view>
	</div>
</template>

<script>
//import WebIM from "./utils/WebIM";
import {setImToken} from '@/utils/auth'

export default {
	name: 'App',
	provide() {    //父组件中通过provide来提供变量，在子组件中通过inject来注入变量。
		return {
			reload: this.reload
		}
	},
	data() {
		return {
			isRouterAlive: true
		}
	},
	created() {

	},
	mounted() {
		const userInfo = JSON.parse(localStorage.getItem("userInfo"));
		/*if (userInfo && !userInfo.isAdmin) {
			let options = {
				apiUrl: WebIM.config.apiURL,
				user: userInfo.userId,
				pwd: userInfo.password,
				appKey: WebIM.config.appkey,
                success: function (response) {
                    setImToken(response.access_token);
                },
                error: function(e){
                    console.log(e)
                }
			};
			WebIM.conn.open(options);
		}*/
	},
	destroyed() {
		//WebIM.conn.close();
	},
	methods: {
		reload() {
			this.isRouterAlive = false;            //先关闭，
			this.$nextTick(function () {
				this.isRouterAlive = true;         //再打开
			})
		}
	}
}
</script>

